package mp

import (
	"duoke/model"
	"duoke/service"
	"duoke/utils/response"
	"github.com/gin-gonic/gin"
)

var TencentStore = new(tencentStoreCtl)

type tencentStoreCtl struct{}

func (ctl *tencentStoreCtl) Result(c *gin.Context) {
	var req model.Result
	if err := c.ShouldBind(&req); err != nil {
		response.Error(c, err.Error(), nil)
		return
	}
	result, err := service.TencentStore.Result(&req)
	if err != nil {
		response.Error(c, err.Error(), nil)
		return
	}
	if err = service.TongueDiagnosis.Save(c, result); err != nil {
		response.Error(c, err.Error(), nil)
		return
	}
	response.Success(c, "success", result.Data)
}
func (ctl *tencentStoreCtl) Report(c *gin.Context) {
	var req model.ReqReport
	if err := c.ShouldBind(&req); err != nil {
		response.Error(c, err.Error(), nil)
		return
	}
	report, err := service.TencentStore.Report(&req)
	if err != nil {
		response.Error(c, err.Error(), nil)
		return
	}
	err = service.TongueDiagnosis.Report(c, report)
	if err != nil {
		response.Error(c, err.Error(), nil)
		return
	}
	response.Success(c, "success", report.Data)
}
